/*
 * Copyright (c) 2016, www.zm0618.com All Rights Reserved..
 */

package com.ibetter.mr.parse.medic;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created by zhaojun on 2016/12/06.
 */
public class CleanDumpShareReducer extends Reducer<Text,NullWritable,LongWritable,LongWritable> {
    @Override
    protected void reduce(Text key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        String ckey=key.toString();
        if (StringUtils.isNotBlank(ckey)){
            String[] kvStr = ckey.split(" ");
            LongWritable doctorIdKeyLong=new LongWritable(0);
            LongWritable medicInfoIdLong=new LongWritable(0);
            String doctorIdStr=kvStr[0];
            String medicInfoIdStr=kvStr[1];
            doctorIdKeyLong.set(Long.parseLong(StringUtils.trim(doctorIdStr)));
            medicInfoIdLong.set(Long.parseLong(StringUtils.trim(medicInfoIdStr)));
            context.write(doctorIdKeyLong,medicInfoIdLong);
        }
    }
}
